package com.ge.modules.sys.controller;

import com.ge.common.utils.PageUtils;
import com.ge.common.utils.Query;
import com.ge.common.utils.R;
import com.ge.modules.entity.TbCommissionExtractinfoEntity;
import com.ge.modules.sys.service.SysCommissionExtractinfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 佣金提现明细
 *
 * @author lanyonglin
 * @email www.baidu.com
 * @date 2018-04-11 17:29:06
 */
@RestController
@RequestMapping("/sys/extractinfo")
public class SysCommissionExtractinfoController {
    @Autowired
    private SysCommissionExtractinfoService sysCommissionExtractinfoService;

    /**
     * 审核列表
     */
    @RequestMapping("/list")
	@RequiresPermissions("sysExtractinfo:list")
    public R list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        Query query = new Query(params);

        List<TbCommissionExtractinfoEntity> tbCommissionExtractinfoEntityList = sysCommissionExtractinfoService.queryList(query);
        int total = sysCommissionExtractinfoService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(tbCommissionExtractinfoEntityList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }


    /**
     * 展示提现信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sysExtractinfo:info")
    public R info(@PathVariable("id") Integer id) {
        TbCommissionExtractinfoEntity tbCommissionExtractinfoEntity = sysCommissionExtractinfoService.queryObject(id);

        return R.ok().put("commissionExtractinfo", tbCommissionExtractinfoEntity);
    }


    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sysExtractinfo:save")
    public R save(@RequestBody TbCommissionExtractinfoEntity tbCommissionExtractinfoEntity) {
        sysCommissionExtractinfoService.save(tbCommissionExtractinfoEntity);

        return R.ok();
    }

    /*
     *审核通过后改变订单状态
     */
    @RequestMapping("/update/pass")
    public R updatePass(@RequestBody TbCommissionExtractinfoEntity tbCommissionExtractinfoEntity) {
        sysCommissionExtractinfoService.updatePass(tbCommissionExtractinfoEntity);
        return R.ok();
    }

    /*
     *审核拒绝后改变订单状态
     */
    @RequestMapping("/update/refuse")
    public R updateRefuse(@RequestBody TbCommissionExtractinfoEntity tbCommissionExtractinfoEntity) {
        sysCommissionExtractinfoService.updateRefuse(tbCommissionExtractinfoEntity);
        return R.ok();
    }

    /*
     *打款后改变订单状态
     */
    @RequestMapping("/update/remit")
    public R updateRemit(@RequestBody TbCommissionExtractinfoEntity tbCommissionExtractinfoEntity) {
        sysCommissionExtractinfoService.updateRemit(tbCommissionExtractinfoEntity);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sysExtractinfo:update")
    public R update(TbCommissionExtractinfoEntity tbCommissionExtractinfoEntity) {
        sysCommissionExtractinfoService.update(tbCommissionExtractinfoEntity);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sysExtractinfo:delete")
    public R delete(@RequestBody Integer[] ids) {
        sysCommissionExtractinfoService.deleteBatch(ids);

        return R.ok();
    }

}
